package com.echo.im.infrastructure.mq.event.model.push;

import com.echo.im.common.model.info.IMRecvInfo;
import com.echo.im.common.contant.MQConstants;
import com.echo.im.infrastructure.mq.event.AbstractPushEvent;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author: echo
 * @time: 2024-08-16
 */
@Component
public class PushMessageEvent extends AbstractPushEvent<IMRecvInfo<?>> {

    @Override
    public String topic() {
        return MQConstants.PUSH_MESSAGE_TOPIC;
    }

    @Override
    public EventMessage<IMRecvInfo<?>> buildEventMessage(IMRecvInfo<?> data) {
        return EventMessage.<IMRecvInfo<?> >builder()
                .id(RandomStringUtils.randomNumeric(11))
                .timestamp(new Date())
                .data(data)
                .build();
    }

}
